package com.example.student.config;

import org.springframework.context.annotation.Configuration;
import org.springframework.web.servlet.config.annotation.CorsRegistry;
import org.springframework.web.servlet.config.annotation.WebMvcConfigurer;

@Configuration
public class CorsConfig implements WebMvcConfigurer {
    @Override
    public void addCorsMappings(CorsRegistry registry){
        // 所有接口
        registry.addMapping("/**")
                // 是否发送cookie
                .allowCredentials(true)
                // 支持域
                .allowedOriginPatterns("http://localhost:5173/")
                .allowedMethods(new String[]{"GET","POST","DELETE","UPDATE"})
                .allowedHeaders("*")
                .exposedHeaders("*");
    }
}
